package org.ecc.android.validations.library.validator;

import android.content.Context;

import org.ecc.android.validations.library.ValidationExecutor;

import java.util.regex.Pattern;

/**
 * Created with org.ecc.android.validations.library.validator
 * User:YangXiuFeng
 * Date:2016/1/14
 * Time:20:19
 */
public class EmailValidation extends ValidationExecutor{
    public static final Pattern EMAIL_ADDRESS
            = Pattern.compile(
            "[a-zA-Z0-9\\+\\.\\_\\%\\-\\+]{1,256}" +
                    "\\@" +
                    "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}" +
                    "(" +
                    "\\." +
                    "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25}" +
                    ")+"
    );
    @Override
    public boolean doValidate(Context context, String text) {
        if(EMAIL_ADDRESS.matcher(text).find()){
            return true;
        }
        return false;
    }
}
